﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ScheduleMaker.DB.Domain;
using NHibernate;
using NHibernate.Criterion;
using NHibernate.Transform;

namespace ScheduleMaker.DB
{
    //TODO: po czym szukac?
    //co zrobic z tym teacherem
    class TeacherDAO : AbstractDAO<Teacher>
    {

        public Teacher findByLogin(string login)
        {
            createSession();
            ICriteria criteria = session.CreateCriteria(typeof(Teacher))
                .Add(Restrictions.Eq("Login", login)).SetResultTransformer(new DistinctRootEntityResultTransformer());
            IList<Teacher> users = criteria.List<Teacher>();
            closeSession();
            return users.ElementAt<Teacher>(0);
        }

    }
}
